/*** From 2003 on, people are allowed to report multiple races ***/
/*** Drop observations with missing race ***/
/*** Run program that converts multiple races into a single race ***/
/*** The program needs the following variables: race, age, hispanic, male, state ***/
/*** The variable hispanic has some missing values, but all of them are before 2003 ***/ 


/*** Create new race variable (needed in the program below) ***/
/*** Follow the IPUMS coding scheme ***/

/* Indicator for White either as a single race or as one of multiple races (1=no, 2=yes) */
gen racwht=1
replace racwht=2 if race==1 | (race>=6 & race<=9) | (race>=15 & race<=19)
replace racwht=. if race==20 | race==21 | race==.

/* Indicator for Black either as a single race or as one of multiple races (1=no, 2=yes) */
gen racblk=1
replace racblk=2 if race==2 | race==6 | (race>=10 & race<=12) | race==15 | race==16 | race==19
replace racblk=. if race==20 | race==21 | race==.

/* Indicator for Asian or Pacific Islander either as a single race or as one of multiple races (1=no, 2=yes) */
gen racapi=1
replace racapi=2 if race==4 | race==5 | race==8 | race==9 | (race>=11 & race<=14) | (race>=16 & race<=19)
replace racapi=. if race==20 | race==21 | race==.

/* Indicator for American Indian or Alaskan Native either as a single race or as one of multiple races (1=no, 2=yes) */
gen racamind=1
replace racamind=2 if race==3 | race==7 | race==10 | race==13 | race==15 | race==17 | race==19
replace racamind=. if race==20 | race==21 | race==.

gen MRMRACE=.
replace MRMRACE=1  if racamind==2 & racapi==2 & racblk==1 & racwht==1
replace MRMRACE=2  if racamind==2 & racapi==1 & racblk==2 & racwht==1
replace MRMRACE=3  if racamind==2 & racapi==1 & racblk==1 & racwht==2
replace MRMRACE=4  if racamind==1 & racapi==2 & racblk==2 & racwht==1
replace MRMRACE=5  if racamind==1 & racapi==2 & racblk==1 & racwht==2
replace MRMRACE=6  if racamind==1 & racapi==1 & racblk==2 & racwht==2
replace MRMRACE=7  if racamind==2 & racapi==2 & racblk==2 & racwht==1
replace MRMRACE=8  if racamind==2 & racapi==2 & racblk==1 & racwht==2
replace MRMRACE=9  if racamind==2 & racapi==1 & racblk==2 & racwht==2
replace MRMRACE=10 if racamind==1 & racapi==2 & racblk==2 & racwht==2
replace MRMRACE=11 if racamind==2 & racapi==2 & racblk==2 & racwht==2
replace MRMRACE=20 if racamind==2 & racapi==1 & racblk==1 & racwht==1
replace MRMRACE=30 if racamind==1 & racapi==2 & racblk==1 & racwht==1
replace MRMRACE=40 if racamind==1 & racapi==1 & racblk==2 & racwht==1
replace MRMRACE=50 if racamind==1 & racapi==1 & racblk==1 & racwht==2

drop racwht racblk racapi racamind


/*** Create variable for age/10 (needed in the program below) ***/
gen AGE10=age/10


/*** Create dummy variable for hispanic (needed in the program below) ***/
gen HISP=hispanic


/*** Create dummy variable for male (needed in the program below) ***/
gen MALE=0
replace MALE=1 if female==0


/*** Create variable with state FIPS codes (needed in the program below) ***/

gen state_name=""
replace state_name="Maine"                if state==11
replace state_name="New Hampshire"        if state==12
replace state_name="Vermont"              if state==13
replace state_name="Massachusetts"        if state==14
replace state_name="Rhode Island"         if state==15
replace state_name="Connecticut"          if state==16
replace state_name="New York"             if state==21
replace state_name="New Jersey"           if state==22
replace state_name="Pennsylvania"         if state==23
replace state_name="Ohio"                 if state==31
replace state_name="Indiana"              if state==32
replace state_name="Illinois"             if state==33
replace state_name="Michigan"             if state==34
replace state_name="Wisconsin"            if state==35
replace state_name="Minnesota"            if state==41
replace state_name="Iowa"                 if state==42
replace state_name="Missouri"             if state==43
replace state_name="North Dakota"         if state==44
replace state_name="South Dakota"         if state==45
replace state_name="Nebraska"             if state==46
replace state_name="Kansas"               if state==47
replace state_name="Delaware"             if state==51
replace state_name="Maryland"             if state==52
replace state_name="District of Columbia" if state==53
replace state_name="Virginia"             if state==54
replace state_name="West Virginia"        if state==55
replace state_name="North Carolina"       if state==56
replace state_name="South Carolina"       if state==57
replace state_name="Georgia"              if state==58
replace state_name="Florida"              if state==59
replace state_name="Kentucky"             if state==61
replace state_name="Tennessee"            if state==62
replace state_name="Alabama"              if state==63
replace state_name="Mississippi"          if state==64
replace state_name="Arkansas"             if state==71
replace state_name="Louisiana"            if state==72
replace state_name="Oklahoma"             if state==73
replace state_name="Texas"                if state==74
replace state_name="Montana"              if state==81
replace state_name="Idaho"                if state==82
replace state_name="Wyoming"              if state==83
replace state_name="Colorado"             if state==84
replace state_name="New Mexico"           if state==85
replace state_name="Arizona"              if state==86
replace state_name="Utah"                 if state==87
replace state_name="Nevada"               if state==88
replace state_name="Washington"           if state==91
replace state_name="Oregon"               if state==92
replace state_name="California"           if state==93
replace state_name="Alaska"               if state==94
replace state_name="Hawaii"               if state==95

gen STATEFIP=.
replace STATEFIP=01 if state_name=="Alabama"
replace STATEFIP=02 if state_name=="Alaska"
replace STATEFIP=04 if state_name=="Arizona"
replace STATEFIP=05 if state_name=="Arkansas"
replace STATEFIP=06 if state_name=="California"
replace STATEFIP=08 if state_name=="Colorado"
replace STATEFIP=09 if state_name=="Connecticut"
replace STATEFIP=10 if state_name=="Delaware"
replace STATEFIP=11 if state_name=="District of Columbia"
replace STATEFIP=12 if state_name=="Florida"
replace STATEFIP=13 if state_name=="Georgia"
replace STATEFIP=15 if state_name=="Hawaii"
replace STATEFIP=16 if state_name=="Idaho"
replace STATEFIP=17 if state_name=="Illinois"
replace STATEFIP=18 if state_name=="Indiana"
replace STATEFIP=19 if state_name=="Iowa"
replace STATEFIP=20 if state_name=="Kansas"
replace STATEFIP=21 if state_name=="Kentucky"
replace STATEFIP=22 if state_name=="Louisiana"
replace STATEFIP=23 if state_name=="Maine"
replace STATEFIP=24 if state_name=="Maryland"
replace STATEFIP=25 if state_name=="Massachusetts"
replace STATEFIP=26 if state_name=="Michigan"
replace STATEFIP=27 if state_name=="Minnesota"
replace STATEFIP=28 if state_name=="Mississippi"
replace STATEFIP=29 if state_name=="Missouri"
replace STATEFIP=30 if state_name=="Montana"
replace STATEFIP=31 if state_name=="Nebraska"
replace STATEFIP=32 if state_name=="Nevada"
replace STATEFIP=33 if state_name=="New Hampshire"
replace STATEFIP=34 if state_name=="New Jersey"
replace STATEFIP=35 if state_name=="New Mexico"
replace STATEFIP=36 if state_name=="New York"
replace STATEFIP=37 if state_name=="North Carolina"
replace STATEFIP=38 if state_name=="North Dakota"
replace STATEFIP=39 if state_name=="Ohio"
replace STATEFIP=40 if state_name=="Oklahoma"
replace STATEFIP=41 if state_name=="Oregon"
replace STATEFIP=42 if state_name=="Pennsylvania"
replace STATEFIP=44 if state_name=="Rhode Island"
replace STATEFIP=45 if state_name=="South Carolina"
replace STATEFIP=46 if state_name=="South Dakota"
replace STATEFIP=47 if state_name=="Tennessee"
replace STATEFIP=48 if state_name=="Texas"
replace STATEFIP=49 if state_name=="Utah"
replace STATEFIP=51 if state_name=="Virginia"
replace STATEFIP=50 if state_name=="Vermont"
replace STATEFIP=53 if state_name=="Washington"
replace STATEFIP=54 if state_name=="West Virginia"
replace STATEFIP=55 if state_name=="Wisconsin"
replace STATEFIP=56 if state_name=="Wyoming"

drop state_name


/*** The program below was taken from IPUMS' website ***/

/***

INFORMATION ABOUT THE PROGRAM

This program is designed to convert or 'bridge' multiple-race 
responses to single-race codes using only state-level geographic 
information. The method is termed the "modified regression method" 
because it is similar to (and based upon) the method and results 
reported in Ingram DD, Parker JD, Schenker N, Weed JA, Hamilton B, 
Arias E, Madans JH. "United States Census 2000 Population with 
Bridged Race Categories." National Center for Health Statistics. 
Vital Health Stat 2(135). 2003.

The following abbreviations are used below: 
 AIAN = American Indian and/or Alaska Native
 API = Asian and/or Pacific Islander
 B = black or African American
 W = white
 SOR = "some other race" 
 
To learn more about this program and/or the variables it creates, 
see Liebler CA and Halpern-Manners A. "A Practical Approach to Using 
Multiple-Race Response Data: A Bridging Method for Public-Use Microdata" 
Demography. 2007. Please cite this program by citing the Liebler and 
Halpern-Manners article.

***/


#delimit ;

* Source: The racial composition of states as of April 1, 2000 
are from Ingram et al. 2003, Table 2, which was derived from 
the Census 2000 Modified Race Data Summary File;

gen lnpctAI=0;	
 label variable lnpctAI "natural log of %AI in state";
replace lnpctAI=	-0.693147181	if STATEFIP==	1	; 
replace lnpctAI=	2.753660712	if STATEFIP==	2	; 
replace lnpctAI=	1.648658626	if STATEFIP==	4	; 
replace lnpctAI=	-0.356674944	if STATEFIP==	5	; 
replace lnpctAI=	0.182321557	if STATEFIP==	6	; 
replace lnpctAI=	0.182321557	if STATEFIP==	8	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	9	; 
replace lnpctAI=	-0.916290732	if STATEFIP==	10	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	11	; 
replace lnpctAI=	-0.916290732	if STATEFIP==	12	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	13	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	15	; 
replace lnpctAI=	0.336472237	if STATEFIP==	16	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	17	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	18	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	19	; 
replace lnpctAI=	0		if STATEFIP==	20	; 
replace lnpctAI=	-1.609437912	if STATEFIP==	21	; 
replace lnpctAI=	-0.510825624	if STATEFIP==	22	; 
replace lnpctAI=	-0.510825624	if STATEFIP==	23	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	24	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	25	; 
replace lnpctAI=	-0.510825624	if STATEFIP==	26	; 
replace lnpctAI=	0.09531018	if STATEFIP==	27	; 
replace lnpctAI=	-0.916290732	if STATEFIP==	28	; 
replace lnpctAI=	-0.693147181	if STATEFIP==	29	; 
replace lnpctAI=	1.824549292	if STATEFIP==	30	; 
replace lnpctAI=	-0.105360516	if STATEFIP==	31	; 
replace lnpctAI=	0.336472237	if STATEFIP==	32	; 
replace lnpctAI=	-1.609437912	if STATEFIP==	33	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	34	; 
replace lnpctAI=	2.282382386	if STATEFIP==	35	; 
replace lnpctAI=	-0.693147181	if STATEFIP==	36	; 
replace lnpctAI=	0.262364264	if STATEFIP==	37	; 
replace lnpctAI=	1.589235205	if STATEFIP==	38	; 
replace lnpctAI=	-1.609437912	if STATEFIP==	39	; 
replace lnpctAI=	2.079441542	if STATEFIP==	40	; 
replace lnpctAI=	0.336472237	if STATEFIP==	41	; 
replace lnpctAI=	-1.609437912	if STATEFIP==	42	; 
replace lnpctAI=	-0.510825624	if STATEFIP==	44	; 
replace lnpctAI=	-0.916290732	if STATEFIP==	45	; 
replace lnpctAI=	2.116255515	if STATEFIP==	46	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	47	; 
replace lnpctAI=	-0.356674944	if STATEFIP==	48	; 
replace lnpctAI=	0.336472237	if STATEFIP==	49	; 
replace lnpctAI=	-0.916290732	if STATEFIP==	50	; 
replace lnpctAI=	-1.203972804	if STATEFIP==	51	; 
replace lnpctAI=	0.470003629	if STATEFIP==	53	; 
replace lnpctAI=	-1.609437912	if STATEFIP==	54	; 
replace lnpctAI=	-0.105360516	if STATEFIP==	55	; 
replace lnpctAI=	0.832909123	if STATEFIP==	56	; 
				
gen pctAI=0;	
 label variable pctAI "% Am.Ind. in state";			
replace pctAI=	0.5	if STATEFIP==	1	; 
replace pctAI=	15.7	if STATEFIP==	2	; 
replace pctAI=	5.2	if STATEFIP==	4	; 
replace pctAI=	0.7	if STATEFIP==	5	; 
replace pctAI=	1.2	if STATEFIP==	6	; 
replace pctAI=	1.2	if STATEFIP==	8	; 
replace pctAI=	0.3	if STATEFIP==	9	; 
replace pctAI=	0.4	if STATEFIP==	10	; 
replace pctAI=	0.3	if STATEFIP==	11	; 
replace pctAI=	0.4	if STATEFIP==	12	; 
replace pctAI=	0.3	if STATEFIP==	13	; 
replace pctAI=	0.3	if STATEFIP==	15	; 
replace pctAI=	1.4	if STATEFIP==	16	; 
replace pctAI=	0.3	if STATEFIP==	17	; 
replace pctAI=	0.3	if STATEFIP==	18	; 
replace pctAI=	0.3	if STATEFIP==	19	; 
replace pctAI=	1	if STATEFIP==	20	; 
replace pctAI=	0.2	if STATEFIP==	21	; 
replace pctAI=	0.6	if STATEFIP==	22	; 
replace pctAI=	0.6	if STATEFIP==	23	; 
replace pctAI=	0.3	if STATEFIP==	24	; 
replace pctAI=	0.3	if STATEFIP==	25	; 
replace pctAI=	0.6	if STATEFIP==	26	; 
replace pctAI=	1.1	if STATEFIP==	27	; 
replace pctAI=	0.4	if STATEFIP==	28	; 
replace pctAI=	0.5	if STATEFIP==	29	; 
replace pctAI=	6.2	if STATEFIP==	30	; 
replace pctAI=	0.9	if STATEFIP==	31	; 
replace pctAI=	1.4	if STATEFIP==	32	; 
replace pctAI=	0.2	if STATEFIP==	33	; 
replace pctAI=	0.3	if STATEFIP==	34	; 
replace pctAI=	9.8	if STATEFIP==	35	; 
replace pctAI=	0.5	if STATEFIP==	36	; 
replace pctAI=	1.3	if STATEFIP==	37	; 
replace pctAI=	4.9	if STATEFIP==	38	; 
replace pctAI=	0.2	if STATEFIP==	39	; 
replace pctAI=	8	if STATEFIP==	40	; 
replace pctAI=	1.4	if STATEFIP==	41	; 
replace pctAI=	0.2	if STATEFIP==	42	; 
replace pctAI=	0.6	if STATEFIP==	44	; 
replace pctAI=	0.4	if STATEFIP==	45	; 
replace pctAI=	8.3	if STATEFIP==	46	; 
replace pctAI=	0.3	if STATEFIP==	47	; 
replace pctAI=	0.7	if STATEFIP==	48	; 
replace pctAI=	1.4	if STATEFIP==	49	; 
replace pctAI=	0.4	if STATEFIP==	50	; 
replace pctAI=	0.3	if STATEFIP==	51	; 
replace pctAI=	1.6	if STATEFIP==	53	; 
replace pctAI=	0.2	if STATEFIP==	54	; 
replace pctAI=	0.9	if STATEFIP==	55	; 
replace pctAI=	2.3	if STATEFIP==	56	; 


gen pctAPI=0; 				
 label variable pctAPI "% Asian or PI in state";		
replace pctAPI=	0.8	if STATEFIP==	1	; 
replace pctAPI=	4.7	if STATEFIP==	2	; 
replace pctAPI=	2.1	if STATEFIP==	4	; 
replace pctAPI=	0.9	if STATEFIP==	5	; 
replace pctAPI=	11.8	if STATEFIP==	6	; 
replace pctAPI=	2.5	if STATEFIP==	8	; 
replace pctAPI=	2.6	if STATEFIP==	9	; 
replace pctAPI=	2.2	if STATEFIP==	10	; 
replace pctAPI=	2.8	if STATEFIP==	11	; 
replace pctAPI=	1.8	if STATEFIP==	12	; 
replace pctAPI=	2.3	if STATEFIP==	13	; 
replace pctAPI=	56.7	if STATEFIP==	15	; 
replace pctAPI=	1.1	if STATEFIP==	16	; 
replace pctAPI=	3.6	if STATEFIP==	17	; 
replace pctAPI=	1	if STATEFIP==	18	; 
replace pctAPI=	1.3	if STATEFIP==	19	; 
replace pctAPI=	1.9	if STATEFIP==	20	; 
replace pctAPI=	0.8	if STATEFIP==	21	; 
replace pctAPI=	1.3	if STATEFIP==	22	; 
replace pctAPI=	0.8	if STATEFIP==	23	; 
replace pctAPI=	4.1	if STATEFIP==	24	; 
replace pctAPI=	4	if STATEFIP==	25	; 
replace pctAPI=	1.9	if STATEFIP==	26	; 
replace pctAPI=	3	if STATEFIP==	27	; 
replace pctAPI=	0.7	if STATEFIP==	28	; 
replace pctAPI=	1.2	if STATEFIP==	29	; 
replace pctAPI=	0.6	if STATEFIP==	30	; 
replace pctAPI=	1.4	if STATEFIP==	31	; 
replace pctAPI=	5.3	if STATEFIP==	32	; 
replace pctAPI=	1.4	if STATEFIP==	33	; 
replace pctAPI=	6	if STATEFIP==	34	; 
replace pctAPI=	1.3	if STATEFIP==	35	; 
replace pctAPI=	5.9	if STATEFIP==	36	; 
replace pctAPI=	1.5	if STATEFIP==	37	; 
replace pctAPI=	0.6	if STATEFIP==	38	; 
replace pctAPI=	1.2	if STATEFIP==	39	; 
replace pctAPI=	1.5	if STATEFIP==	40	; 
replace pctAPI=	3.4	if STATEFIP==	41	; 
replace pctAPI=	1.9	if STATEFIP==	42	; 
replace pctAPI=	2.5	if STATEFIP==	44	; 
replace pctAPI=	1	if STATEFIP==	45	; 
replace pctAPI=	0.6	if STATEFIP==	46	; 
replace pctAPI=	1.1	if STATEFIP==	47	; 
replace pctAPI=	2.9	if STATEFIP==	48	; 
replace pctAPI=	2.5	if STATEFIP==	49	; 
replace pctAPI=	0.9	if STATEFIP==	50	; 
replace pctAPI=	3.9	if STATEFIP==	51	; 
replace pctAPI=	6.1	if STATEFIP==	53	; 
replace pctAPI=	0.6	if STATEFIP==	54	; 
replace pctAPI=	1.8	if STATEFIP==	55	; 
replace pctAPI=	0.7	if STATEFIP==	56	; 
				
gen pctB=0; 						
 label variable pctB "% Black in state";		
replace pctB=	26.1	if STATEFIP==	1	; 
replace pctB=	3.7	if STATEFIP==	2	; 
replace pctB=	3.3	if STATEFIP==	4	; 
replace pctB=	15.7	if STATEFIP==	5	; 
replace pctB=	7	if STATEFIP==	6	; 
replace pctB=	4	if STATEFIP==	8	; 
replace pctB=	9.8	if STATEFIP==	9	; 
replace pctB=	19.6	if STATEFIP==	10	; 
replace pctB=	61.1	if STATEFIP==	11	; 
replace pctB=	15.2	if STATEFIP==	12	; 
replace pctB=	29	if STATEFIP==	13	; 
replace pctB=	1.9	if STATEFIP==	15	; 
replace pctB=	0.5	if STATEFIP==	16	; 
replace pctB=	15.3	if STATEFIP==	17	; 
replace pctB=	8.5	if STATEFIP==	18	; 
replace pctB=	2.2	if STATEFIP==	19	; 
replace pctB=	5.9	if STATEFIP==	20	; 
replace pctB=	7.4	if STATEFIP==	21	; 
replace pctB=	32.6	if STATEFIP==	22	; 
replace pctB=	0.6	if STATEFIP==	23	; 
replace pctB=	28.3	if STATEFIP==	24	; 
replace pctB=	6.4	if STATEFIP==	25	; 
replace pctB=	14.4	if STATEFIP==	26	; 
replace pctB=	3.7	if STATEFIP==	27	; 
replace pctB=	36.4	if STATEFIP==	28	; 
replace pctB=	11.3	if STATEFIP==	29	; 
replace pctB=	0.3	if STATEFIP==	30	; 
replace pctB=	4.1	if STATEFIP==	31	; 
replace pctB=	7	if STATEFIP==	32	; 
replace pctB=	0.8	if STATEFIP==	33	; 
replace pctB=	14.4	if STATEFIP==	34	; 
replace pctB=	2.1	if STATEFIP==	35	; 
replace pctB=	17.6	if STATEFIP==	36	; 
replace pctB=	21.8	if STATEFIP==	37	; 
replace pctB=	0.6	if STATEFIP==	38	; 
replace pctB=	11.6	if STATEFIP==	39	; 
replace pctB=	7.7	if STATEFIP==	40	; 
replace pctB=	1.7	if STATEFIP==	41	; 
replace pctB=	10.3	if STATEFIP==	42	; 
replace pctB=	5.7	if STATEFIP==	44	; 
replace pctB=	29.7	if STATEFIP==	45	; 
replace pctB=	0.7	if STATEFIP==	46	; 
replace pctB=	16.5	if STATEFIP==	47	; 
replace pctB=	11.8	if STATEFIP==	48	; 
replace pctB=	0.9	if STATEFIP==	49	; 
replace pctB=	0.5	if STATEFIP==	50	; 
replace pctB=	19.9	if STATEFIP==	51	; 
replace pctB=	3.4	if STATEFIP==	53	; 
replace pctB=	3.2	if STATEFIP==	54	; 
replace pctB=	5.8	if STATEFIP==	55	; 
replace pctB=	0.8	if STATEFIP==	56	; 
				
gen pctBsq=0; 				
  label variable pctBsq "% Black in state, squared";
replace pctBsq=	681.21	if STATEFIP==	1	; 
replace pctBsq=	13.69	if STATEFIP==	2	; 
replace pctBsq=	10.89	if STATEFIP==	4	; 
replace pctBsq=	246.49	if STATEFIP==	5	; 
replace pctBsq=	49	if STATEFIP==	6	; 
replace pctBsq=	16	if STATEFIP==	8	; 
replace pctBsq=	96.04	if STATEFIP==	9	; 
replace pctBsq=	384.16	if STATEFIP==	10	; 
replace pctBsq=	3733.21	if STATEFIP==	11	; 
replace pctBsq=	231.04	if STATEFIP==	12	; 
replace pctBsq=	841	if STATEFIP==	13	; 
replace pctBsq=	3.61	if STATEFIP==	15	; 
replace pctBsq=	0.25	if STATEFIP==	16	; 
replace pctBsq=	234.09	if STATEFIP==	17	; 
replace pctBsq=	72.25	if STATEFIP==	18	; 
replace pctBsq=	4.84	if STATEFIP==	19	; 
replace pctBsq=	34.81	if STATEFIP==	20	; 
replace pctBsq=	54.76	if STATEFIP==	21	; 
replace pctBsq=	1062.76	if STATEFIP==	22	; 
replace pctBsq=	0.36	if STATEFIP==	23	; 
replace pctBsq=	800.89	if STATEFIP==	24	; 
replace pctBsq=	40.96	if STATEFIP==	25	; 
replace pctBsq=	207.36	if STATEFIP==	26	; 
replace pctBsq=	13.69	if STATEFIP==	27	; 
replace pctBsq=	1324.96	if STATEFIP==	28	; 
replace pctBsq=	127.69	if STATEFIP==	29	; 
replace pctBsq=	0.09	if STATEFIP==	30	; 
replace pctBsq=	16.81	if STATEFIP==	31	; 
replace pctBsq=	49	if STATEFIP==	32	; 
replace pctBsq=	0.64	if STATEFIP==	33	; 
replace pctBsq=	207.36	if STATEFIP==	34	; 
replace pctBsq=	4.41	if STATEFIP==	35	; 
replace pctBsq=	309.76	if STATEFIP==	36	; 
replace pctBsq=	475.24	if STATEFIP==	37	; 
replace pctBsq=	0.36	if STATEFIP==	38	; 
replace pctBsq=	134.56	if STATEFIP==	39	; 
replace pctBsq=	59.29	if STATEFIP==	40	; 
replace pctBsq=	2.89	if STATEFIP==	41	; 
replace pctBsq=	106.09	if STATEFIP==	42	; 
replace pctBsq=	32.49	if STATEFIP==	44	; 
replace pctBsq=	882.09	if STATEFIP==	45	; 
replace pctBsq=	0.49	if STATEFIP==	46	; 
replace pctBsq=	272.25	if STATEFIP==	47	; 
replace pctBsq=	139.24	if STATEFIP==	48	; 
replace pctBsq=	0.81	if STATEFIP==	49	; 
replace pctBsq=	0.25	if STATEFIP==	50	; 
replace pctBsq=	396.01	if STATEFIP==	51	; 
replace pctBsq=	11.56	if STATEFIP==	53	; 
replace pctBsq=	10.24	if STATEFIP==	54	; 
replace pctBsq=	33.64	if STATEFIP==	55	; 
replace pctBsq=	0.64	if STATEFIP==	56	; 

gen pct2race=0;	
 label variable pct2race "% 2+ races or non-Hisp 'other' in state";		
replace pct2race=	0.8	if STATEFIP==	1	; 
replace pct2race=	4.6	if STATEFIP==	2	; 
replace pct2race=	1.3	if STATEFIP==	4	; 
replace pct2race=	1.1	if STATEFIP==	5	; 
replace pct2race=	2.2	if STATEFIP==	6	; 
replace pct2race=	1.6	if STATEFIP==	8	; 
replace pct2race=	1.1	if STATEFIP==	9	; 
replace pct2race=	1.1	if STATEFIP==	10	; 
replace pct2race=	1.3	if STATEFIP==	11	; 
replace pct2race=	1	if STATEFIP==	12	; 
replace pct2race=	0.9	if STATEFIP==	13	; 
replace pct2race=	15.2	if STATEFIP==	15	; 
replace pct2race=	1.3	if STATEFIP==	16	; 
replace pct2race=	0.9	if STATEFIP==	17	; 
replace pct2race=	0.9	if STATEFIP==	18	; 
replace pct2race=	0.8	if STATEFIP==	19	; 
replace pct2race=	1.5	if STATEFIP==	20	; 
replace pct2race=	0.8	if STATEFIP==	21	; 
replace pct2race=	0.7	if STATEFIP==	22	; 
replace pct2race=	0.8	if STATEFIP==	23	; 
replace pct2race=	1.3	if STATEFIP==	24	; 
replace pct2race=	1.1	if STATEFIP==	25	; 
replace pct2race=	1.3	if STATEFIP==	26	; 
replace pct2race=	1.2	if STATEFIP==	27	; 
replace pct2race=	0.6	if STATEFIP==	28	; 
replace pct2race=	1.1	if STATEFIP==	29	; 
replace pct2race=	1.5	if STATEFIP==	30	; 
replace pct2race=	1	if STATEFIP==	31	; 
replace pct2race=	2.1	if STATEFIP==	32	; 
replace pct2race=	0.8	if STATEFIP==	33	; 
replace pct2race=	1.1	if STATEFIP==	34	; 
replace pct2race=	1.4	if STATEFIP==	35	; 
replace pct2race=	1.3	if STATEFIP==	36	; 
replace pct2race=	0.9	if STATEFIP==	37	; 
replace pct2race=	0.9	if STATEFIP==	38	; 
replace pct2race=	1.1	if STATEFIP==	39	; 
replace pct2race=	4	if STATEFIP==	40	; 
replace pct2race=	2.1	if STATEFIP==	41	; 
replace pct2race=	0.8	if STATEFIP==	42	; 
replace pct2race=	1.3	if STATEFIP==	44	; 
replace pct2race=	0.7	if STATEFIP==	45	; 
replace pct2race=	1.1	if STATEFIP==	46	; 
replace pct2race=	0.8	if STATEFIP==	47	; 
replace pct2race=	0.9	if STATEFIP==	48	; 
replace pct2race=	1.2	if STATEFIP==	49	; 
replace pct2race=	1	if STATEFIP==	50	; 
replace pct2race=	1.3	if STATEFIP==	51	; 
replace pct2race=	2.6	if STATEFIP==	53	; 
replace pct2race=	0.8	if STATEFIP==	54	; 
replace pct2race=	0.9	if STATEFIP==	55	; 
replace pct2race=	1.2	if STATEFIP==	56	; 

* 14 states have no cities of more than 1 million population; 
* source for total state pop & # not metro: Census table GCT-PH1: state;

gen medmetro= 0;
 label variable medmetro "MSA less than 1 million";
replace medmetro=	0.6991	 if STATEFIP==	1	;
replace medmetro=	0.4152	 if STATEFIP==	2	;
replace medmetro=	0.8001	 if STATEFIP==	10	;
replace medmetro=	0.7232	 if STATEFIP==	15	;
replace medmetro=	0.3925	 if STATEFIP==	16	;
replace medmetro=	0.4532	 if STATEFIP==	19	;
replace medmetro=	0.3660	 if STATEFIP==	23	;
replace medmetro=	0.3386	 if STATEFIP==	30	;
replace medmetro=	0.5258	 if STATEFIP==	31	;
replace medmetro=	0.5690	 if STATEFIP==	35	;
replace medmetro=	0.4422	 if STATEFIP==	38	;
replace medmetro=	0.3457	 if STATEFIP==	46	;
replace medmetro=	0.2782	 if STATEFIP==	50	;
replace medmetro=	0.3000	 if STATEFIP==	56	;

gen nonmetro= 0;
 label variable nonmetro "not in metro area";
replace nonmetro=	0.3009	 if STATEFIP==	1	;
replace nonmetro=	0.5848	 if STATEFIP==	2	;
replace nonmetro=	0.1999	 if STATEFIP==	10	;
replace nonmetro=	0.2768	 if STATEFIP==	15	;
replace nonmetro=	0.6075	 if STATEFIP==	16	;
replace nonmetro=	0.5468	 if STATEFIP==	19	;
replace nonmetro=	0.6340	 if STATEFIP==	23	;
replace nonmetro=	0.6614	 if STATEFIP==	30	;
replace nonmetro=	0.4742	 if STATEFIP==	31	;
replace nonmetro=	0.4310	 if STATEFIP==	35	;
replace nonmetro=	0.5578	 if STATEFIP==	38	;
replace nonmetro=	0.6543	 if STATEFIP==	46	;
replace nonmetro=	0.7218	 if STATEFIP==	50	;
replace nonmetro=	0.7000	 if STATEFIP==	56	;

* 11 states and DC have 1+ 'big' city and no big cities cross 
  its state lines;
* source for central city population is: Census table GCT-PH1: 
  Population, Housing Units, Area, and Density: 2000 (SF1) 
  US and PR -- Metropolitan Area, in Central City, Not in 
  Central City, County, and (in selected States) County Subdivision;
  
gen bigurban= 0; 
 label variable bigurban "in central city, MSA >= 1 million";
replace bigurban=	0.30194982	 if STATEFIP==	6	;
replace bigurban=	0.128947302	 if STATEFIP==	8	;
replace bigurban=	0.048375233	 if STATEFIP==	9	;
replace bigurban=	1		 if STATEFIP==	11	;
replace bigurban=	0.146517683	 if STATEFIP==	12	;
replace bigurban=	0.050873559	 if STATEFIP==	13	;
replace bigurban=	0.114202672	 if STATEFIP==	22	;
replace bigurban=	0.142947226	 if STATEFIP==	26	;
replace bigurban=	0.454740787	 if STATEFIP==	36	;
replace bigurban=	0.182724202	 if STATEFIP==	40	;
replace bigurban=	0.300103396	 if STATEFIP==	48	;
replace bigurban=	0.127595807	 if STATEFIP==	49	;

gen bigsubrb= 0;
 label variable bigsubrb "outside central city, MSA >= 1 million";
replace bigsubrb=	0.461780454	 if STATEFIP==	6	;
replace bigsubrb=	0.361439587	 if STATEFIP==	8	;
replace bigsubrb=	0.299029676	 if STATEFIP==	9	;
replace bigsubrb=	0	 	 if STATEFIP==	11	;
replace bigsubrb=	0.488469989	 if STATEFIP==	12	;
replace bigsubrb=	0.451443867	 if STATEFIP==	13	;
replace bigsubrb=	0.185133462	 if STATEFIP==	22	;
replace bigsubrb=	0.413484445	 if STATEFIP==	26	;
replace bigsubrb=	0.300745866	 if STATEFIP==	36	;
replace bigsubrb=	0.131229616	 if STATEFIP==	40	;
replace bigsubrb=	0.28697212	 if STATEFIP==	48	;
replace bigsubrb=	0.469723071	 if STATEFIP==	49	;

replace medmetro=	0.203166702	 if STATEFIP==	6	;
replace medmetro=	0.348356912	 if STATEFIP==	8	;
replace medmetro=	0.608941541	 if STATEFIP==	9	;
replace medmetro=	0	 	 if STATEFIP==	11	;
replace medmetro=	0.29337837	 if STATEFIP==	12	;
replace medmetro=	0.189882725	 if STATEFIP==	13	;
replace medmetro=	0.454798594	 if STATEFIP==	22	;
replace medmetro=	0.265574873	 if STATEFIP==	26	;
replace medmetro=	0.165288916	 if STATEFIP==	36	;
replace medmetro=	0.294151775	 if STATEFIP==	40	;
replace medmetro=	0.261381836	 if STATEFIP==	48	;
replace medmetro=	0.167735626	 if STATEFIP==	49	;

replace nonmetro=	0.033103025	 if STATEFIP==	6	;
replace nonmetro=	0.161256199	 if STATEFIP==	8	;
replace nonmetro=	0.043653549	 if STATEFIP==	9	;
replace nonmetro=	0		 if STATEFIP==	11	;
replace nonmetro=	0.071633958	 if STATEFIP==	12	;
replace nonmetro=	0.307799849	 if STATEFIP==	13	;
replace nonmetro=	0.245865272	 if STATEFIP==	22	;
replace nonmetro=	0.177993457	 if STATEFIP==	26	;
replace nonmetro=	0.079224431	 if STATEFIP==	36	;
replace nonmetro=	0.391894406	 if STATEFIP==	40	;
replace nonmetro=	0.151542647	 if STATEFIP==	48	;
replace nonmetro=	0.234945497	 if STATEFIP==	49	;

* 25 states have at least one city that crosses state lines;
* Source for proportions of city populations in each state: Census 
  table GCT-PH1: Population, Housing Units Area, and Density: 2000 (SF1)
; 
replace bigurban=	0.414412241	 if STATEFIP==	4	;
replace bigurban=	0.011355668	 if STATEFIP==	5	;
replace bigurban=	0.282950925	 if STATEFIP==	17	;
replace bigurban=	0.150714862	 if STATEFIP==	18	;
replace bigurban=	0.10598629	 if STATEFIP==	20	;
replace bigurban=	0.075349134	 if STATEFIP==	21	;
replace bigurban=	0.153141576	 if STATEFIP==	24	;
replace bigurban=	0.152262797	 if STATEFIP==	25	;
replace bigurban=	0.131562313	 if STATEFIP==	27	;
replace bigurban=	0.022491049	 if STATEFIP==	28	;
replace bigurban=	0.151907607	 if STATEFIP==	29	;
replace bigurban=	0.215681614	 if STATEFIP==	32	;
replace bigurban=	0.001811942	 if STATEFIP==	33	;
replace bigurban=	0.089741393	 if STATEFIP==	34	;
replace bigurban=	0.215302513	 if STATEFIP==	37	;
replace bigurban=	0.144795427	 if STATEFIP==	39	;
replace bigurban=	0.161220509	 if STATEFIP==	41	;
replace bigurban=	0.125408903	 if STATEFIP==	42	;
replace bigurban=	0.390805241	 if STATEFIP==	44	;
replace bigurban=	0.020518167	 if STATEFIP==	45	;
replace bigurban=	0.210530644	 if STATEFIP==	47	;
replace bigurban=	0.179054064	 if STATEFIP==	51	;
replace bigurban=	0.150236534	 if STATEFIP==	53	;
replace bigurban=	0.003924841	 if STATEFIP==	54	;
replace bigurban=	0.127589752	 if STATEFIP==	55	;

replace bigsubrb=	0.249620572	 if STATEFIP==	4	;
replace bigsubrb=	0.00767104	 if STATEFIP==	5	;
replace bigsubrb=	0.431470822	 if STATEFIP==	17	;
replace bigsubrb=	0.159095622	 if STATEFIP==	18	;
replace bigsubrb=	0.156625402	 if STATEFIP==	20	;
replace bigsubrb=	0.214556845	 if STATEFIP==	21	;
replace bigsubrb=	0.718801822	 if STATEFIP==	24	;
replace bigsubrb=	0.419647665	 if STATEFIP==	25	;
replace bigsubrb=	0.451598424	 if STATEFIP==	27	;
replace bigsubrb=	0.01519327	 if STATEFIP==	28	;
replace bigsubrb=	0.397457556	 if STATEFIP==	29	;
replace bigsubrb=	0.489057566	 if STATEFIP==	32	;
replace bigsubrb=	0.00529123	 if STATEFIP==	33	;
replace bigsubrb=	0.736620477	 if STATEFIP==	34	;
replace bigsubrb=	0.255833222	 if STATEFIP==	37	;
replace bigsubrb=	0.296930475	 if STATEFIP==	39	;
replace bigsubrb=	0.298466011	 if STATEFIP==	41	;
replace bigsubrb=	0.380113017	 if STATEFIP==	42	;
replace bigsubrb=	0.520700703	 if STATEFIP==	44	;
replace bigsubrb=	0.020512119	 if STATEFIP==	45	;
replace bigsubrb=	0.177718631	 if STATEFIP==	47	;
replace bigsubrb=	0.346353879	 if STATEFIP==	51	;
replace bigsubrb=	0.318001902	 if STATEFIP==	53	;
replace bigsubrb=	0.061380765	 if STATEFIP==	54	;
replace bigsubrb=	0.170843691	 if STATEFIP==	55	;

replace medmetro=	0.218314625	 if STATEFIP==	4	;
replace medmetro=	0.475107728	 if STATEFIP==	5	;
replace medmetro=	0.134395332	 if STATEFIP==	17	;
replace medmetro=	0.412155445	 if STATEFIP==	18	;
replace medmetro=	0.303171977	 if STATEFIP==	20	;
replace medmetro=	0.198271846	 if STATEFIP==	21	;
replace medmetro=	0.055282691	 if STATEFIP==	24	;
replace medmetro=	0.389080526	 if STATEFIP==	25	;
replace medmetro=	0.120848773	 if STATEFIP==	27	;
replace medmetro=	0.322169836	 if STATEFIP==	28	;
replace medmetro=	0.128857875	 if STATEFIP==	29	;
replace medmetro=	0.16989106	 if STATEFIP==	32	;
replace medmetro=	0.591462438	 if STATEFIP==	33	;
replace medmetro=	0.17363813	 if STATEFIP==	34	;
replace medmetro=	0.204332593	 if STATEFIP==	37	;
replace medmetro=	0.36983601	 if STATEFIP==	39	;
replace medmetro=	0.271700261	 if STATEFIP==	41	;
replace medmetro=	0.340621171	 if STATEFIP==	42	;
replace medmetro=	0.029382278	 if STATEFIP==	44	;
replace medmetro=	0.658609197	 if STATEFIP==	45	;
replace medmetro=	0.290596196	 if STATEFIP==	47	;
replace medmetro=	0.255556427	 if STATEFIP==	51	;
replace medmetro=	0.362954883	 if STATEFIP==	53	;
replace medmetro=	0.358047473	 if STATEFIP==	54	;
replace medmetro=	0.380263159	 if STATEFIP==	55	;

replace nonmetro=	0.117652562	 if STATEFIP==	4	;
replace nonmetro=	0.505865564	 if STATEFIP==	5	;
replace nonmetro=	0.151182922	 if STATEFIP==	17	;
replace nonmetro=	0.278034071	 if STATEFIP==	18	;
replace nonmetro=	0.434216331	 if STATEFIP==	20	;
replace nonmetro=	0.511822175	 if STATEFIP==	21	;
replace nonmetro=	0.072773911	 if STATEFIP==	24	;
replace nonmetro=	0.039009012	 if STATEFIP==	25	;
replace nonmetro=	0.29599049	 if STATEFIP==	27	;
replace nonmetro=	0.640145845	 if STATEFIP==	28	;
replace nonmetro=	0.321776962	 if STATEFIP==	29	;
replace nonmetro=	0.12536976	 if STATEFIP==	32	;
replace nonmetro=	0.401434391	 if STATEFIP==	33	;
replace nonmetro=	0	 	 if STATEFIP==	34	;
replace nonmetro=	0.324531671	 if STATEFIP==	37	;
replace nonmetro=	0.188438088	 if STATEFIP==	39	;
replace nonmetro=	0.268613219	 if STATEFIP==	41	;
replace nonmetro=	0.153856908	 if STATEFIP==	42	;
replace nonmetro=	0.059111778	 if STATEFIP==	44	;
replace nonmetro=	0.300360517	 if STATEFIP==	45	;
replace nonmetro=	0.321154529	 if STATEFIP==	47	;
replace nonmetro=	0.219035631	 if STATEFIP==	51	;
replace nonmetro=	0.16880668	 if STATEFIP==	53	;
replace nonmetro=	0.576646921	 if STATEFIP==	54	;
replace nonmetro=	0.321303397	 if STATEFIP==	55	;

gen AIPROB=0; 
label variable AIPROB  "probability of reporting Am. Ind. and/or Alaskan Native";
replace AIPROB=1 if MRMRACE==20; 
gen APIPROB=0; 
label variable APIPROB "probability of reporting Asian and/or PI";
replace APIPROB=1 if MRMRACE==30; 
gen BPROB=0; 
label variable BPROB "probability of reporting black";
replace BPROB=1 if MRMRACE==40; 
gen WPROB=0; 
label variable WPROB "probability of reporting white";
replace WPROB=1 if MRMRACE==50; 

gen constant=1;
gen notAI=0 ;   replace notAI=1 if MRMRACE==10;
gen notAPI=0; 
gen notB=0  ;    replace notB=1 if MRMRACE==1 | MRMRACE==8;

gen northest= 0; replace northest=1 if STATEFIP==09 | STATEFIP==23 |  
STATEFIP==25 | STATEFIP==33 | STATEFIP==34 | STATEFIP==36 |  
STATEFIP==42 | STATEFIP==44 | STATEFIP==50;
 label variable northest "northeast region";

gen midwest= 0; replace midwest=1 if STATEFIP==17 | STATEFIP==18 | 
STATEFIP==19 | STATEFIP==20 | STATEFIP==26 | STATEFIP==27 |  
STATEFIP==29 | STATEFIP==31 | STATEFIP==38 | STATEFIP==39 |  
STATEFIP==46 | STATEFIP==55;
 label variable midwest "midwest region";

gen south= 0; replace south=1 if STATEFIP==01 | STATEFIP==05 | 
STATEFIP==10 | STATEFIP==11 | STATEFIP==12 | STATEFIP==13 | 
STATEFIP==21 | STATEFIP==22 | STATEFIP==24 | STATEFIP==28 | 
STATEFIP==37 | STATEFIP==40 | STATEFIP==45 | STATEFIP==47 | 
STATEFIP==48 | STATEFIP==51 | STATEFIP==54; 
 label variable south "south region";
 
gen west=0; replace west=1 if STATEFIP==02 | STATEFIP==04 | 
STATEFIP==06 | STATEFIP==08 | STATEFIP==15 | STATEFIP==16 | 
STATEFIP==30 | STATEFIP==32 | STATEFIP==35 | STATEFIP==41 | 
STATEFIP==49 | STATEFIP==53 | STATEFIP==56; 
 label variable west "west region";

* MRMRACE=1 IS AI-API    ==> predict AI and API, then rescale;
gen mrm1AI =0; label variable mrm1AI "regression answer: AI, MRD group 1";
replace mrm1AI =
 (notAI    *   0) +
 (notAPI   *   2.83058) + 
 (notB     *   0.97010) + 
 (AGE10    *  -0.03967) + 
 (HISP     *   0.84013) + 
 (MALE     *   0.01914) + 
 (northest *   0.59649) + 
 (midwest  *   0.43237) +
 (south    *  -0.22255) + 
 (bigsubrb *   0.15744) + 
 (medmetro *  -0.17318) + 
 (nonmetro *   0.25013) + 
 (lnpctAI  *   0.56512) +
 (pctAPI   *   0.04203) + 
 (pctB     *   0.03921) + 
 (pct2race *  -0.09723) + 
 (constant *  -5.29417)
if MRMRACE==1;
gen AItemp1= exp(mrm1AI)/(1+exp(mrm1AI)) if MRMRACE==1;

gen mrm1API =0; label variable mrm1API "regression answer: API, MRD group 1";
replace mrm1API =
 (notAI    *   2.78725) +
 (notAPI   *   0) + 
 (notB     *   1.61570) + 
 (AGE10    *   0.01946) + 
 (HISP     *   0.21507) + 
 (MALE     *   0.01283) + 
 (northest *  -0.13221) + 
 (midwest  *  -0.15172) +
 (south    *  -0.24854) + 
 (bigsubrb *   0.46028) + 
 (medmetro *  -0.09493) + 
 (nonmetro *  -0.15342) + 
 (lnpctAI  *   0.06996) +
 (pctAPI   *   0.03741) + 
 (pctB     *   0.03590) + 
 (pct2race *   0.06402) + 
 (constant *  -5.73987)
if MRMRACE==1;
gen APItemp1= exp(mrm1API)/(1+exp(mrm1API)) if MRMRACE==1;

gen rescale1=1/(AItemp1+APItemp1); 
replace AIPROB = AItemp1 * rescale1 if MRMRACE==1;
replace APIPROB = APItemp1 * rescale1 if MRMRACE==1;
drop  mrm1AI AItemp1 mrm1API APItemp1 rescale1;

* MRMRACE=2 IS AI-B   ==> predict Black; 
gen mrm2B =0; label variable mrm2B "regression answer: Black, MRD group 2";
replace mrm2B =
 (AGE10    *  -0.05461) + 
 (HISP     *  -1.92602) + 
 (MALE     *  -0.12359) + 
 (northest *  -0.88349) + 
 (midwest  *  -1.70126) +
 (south    *  -0.97935) + 
 (bigsubrb *  -0.44211) + 
 (medmetro *   0.88281) + 
 (nonmetro *  -0.38427) + 
 (lnpctAI  *  -0.43045) +
 (pctBsq   * 0.0000258) + 
 (pct2race *  -0.16934) + 
 (constant *   3.08086)
if MRMRACE==2;
replace BPROB= exp(mrm2B)/(1+exp(mrm2B)) if MRMRACE==2; 
replace AIPROB= 1-BPROB if MRMRACE==2; 
drop mrm2B;

* MRMRACE=3 IS AI-W   ==> predict AI ; 
gen mrm3AI =0; label variable mrm3AI "regression answer: AI, MRD group 3";
replace mrm3AI =
 (AGE10    *  -0.08968) + 
 (HISP     *   0.88834) + 
 (MALE     *   0.00972) + 
 (northest *   0.21233) + 
 (midwest  *   0.09144) +
 (south    *  -0.28494) + 
 (bigsubrb *  -0.22069) + 
 (medmetro *  -0.44238) + 
 (nonmetro *  -0.13978) + 
 (lnpctAI  *   0.51235) +
 (pct2race *  -0.07906) + 
 (constant *  -0.70527) 
if MRMRACE==3;
replace AIPROB= exp(mrm3AI)/(1+exp(mrm3AI)) if MRMRACE==3; 
replace WPROB= 1-AIPROB if MRMRACE==3; 
drop mrm3AI;

* MRMRACE=4 IS API-B  ==> predict Black;
gen mrm4B =0; label variable mrm4B "regression answer: Black, MRD group 4";
replace mrm4B =
 (AGE10    *  0.05669) + 
 (HISP     * -0.10458) + 
 (MALE     *  0.33642) + 
 (northest * -0.45997) + 
 (midwest  * -3.92403) +
 (south    * -1.48264) + 
 (bigsubrb *  1.46590) + 
 (medmetro *  1.67953) + 
 (nonmetro *  0.13301) + 
 (pctAPI   * -0.13245) +
 (pctB     *  0.02078) + 
 (pct2race *  0.31250) + 
 (constant *  0.45883)
if MRMRACE==4;
replace BPROB= exp(mrm4B)/(1+exp(mrm4B)) if MRMRACE==4; 
replace APIPROB= 1-BPROB if MRMRACE==4; 
drop mrm4B;

* MRMRACE=5 IS API-W  ==> predict API ;
gen mrm5API =0; label variable mrm5API "regression answer: API, MRD group 5";
replace mrm5API =
 (AGE10    *  0.09568) + 
 (HISP     *  0.19303) + 
 (MALE     *  0.01393) + 
 (northest * -0.05520) + 
 (midwest  * -0.06453) +
 (south    *  0.12694) + 
 (bigsubrb *  0.50556) + 
 (medmetro *  0.07443) + 
 (nonmetro * -0.62956) + 
 (pctAPI   *  0.00735) +
 (pct2race *  0.09791) + 
 (constant * -1.18887)
if MRMRACE==5;
replace APIPROB= exp(mrm5API)/(1+exp(mrm5API)) if MRMRACE==5; 
replace WPROB= 1-APIPROB if MRMRACE==5; 
drop mrm5API;

* MRMRACE=6 IS B-W    ==> predict Black;
gen mrm6B =0; label variable mrm6B "regression answer: Black, MRD group 6";
replace mrm6B =
 (AGE10    *  0.05532) + 
 (HISP     * -0.52253) + 
 (MALE     *  0.11948) + 
 (northest * -0.25363) + 
 (midwest  *  0.17140) +
 (south    * -0.64386) + 
 (bigsubrb * -0.07649) + 
 (medmetro *  0.28938) + 
 (nonmetro *  0.57636) + 
 (pctBsq   *  0.00079) + 
 (pct2race *  0.31679) + 
 (constant * -0.17533)
if MRMRACE==6;
replace BPROB= exp(mrm6B)/(1+exp(mrm6B)) if MRMRACE==6; 
replace WPROB= 1-BPROB if MRMRACE==6; 
drop mrm6B;

* MRMRACE=7 IS AI-API-B  ==> predict AI, API, and B, then rescale;
gen mrm7AI =0; label variable mrm7AI "regression answer: AI, MRD group 7";
replace mrm7AI =
 (notAI    *   0) +
 (notAPI   *   2.83058) + 
 (notB     *   0.97010) + 
 (AGE10    *  -0.03967) + 
 (HISP     *   0.84013) + 
 (MALE     *   0.01914) + 
 (northest *   0.59649) + 
 (midwest  *   0.43237) +
 (south    *  -0.22255) + 
 (bigsubrb *   0.15744) + 
 (medmetro *  -0.17318) + 
 (nonmetro *   0.25013) + 
 (lnpctAI  *   0.56512) +
 (pctAPI   *   0.04203) + 
 (pctB     *   0.03921) + 
 (pct2race *  -0.09723) + 
 (constant *  -5.29417)
if MRMRACE==7;

gen mrm7API =0; label variable mrm7API "regression answer: API, MRD group 7";
replace mrm7API =
 (notAI    *   2.78725) +
 (notAPI   *   0) + 
 (notB     *   1.61570) + 
 (AGE10    *   0.01946) + 
 (HISP     *   0.21507) + 
 (MALE     *   0.01283) + 
 (northest *  -0.13221) + 
 (midwest  *  -0.15172) +
 (south    *  -0.24854) + 
 (bigsubrb *   0.46028) + 
 (medmetro *  -0.09493) + 
 (nonmetro *  -0.15342) + 
 (lnpctAI  *   0.06996) +
 (pctAPI   *   0.03741) + 
 (pctB     *   0.03590) + 
 (pct2race *   0.06402) + 
 (constant *  -5.73987)
if MRMRACE==7;

gen mrm7B =0; label variable mrm7B "regression answer: B, MRD group 7";
replace mrm7B =
 (notAI    *   2.19772) +
 (notAPI   *   3.06153) + 
 (notB     *   0) + 
 (AGE10    *  -0.01691) + 
 (HISP     *  -0.58721) + 
 (MALE     *  -0.08093) + 
 (northest *   0.40115) + 
 (midwest  *   0.20136) +
 (south    *  -0.29365) + 
 (bigsubrb *   0.12070) + 
 (medmetro *  -0.11129) + 
 (nonmetro *  -0.12077) + 
 (lnpctAI  *  -0.00347) +
 (pctAPI   *   0.05396) + 
 (pctB     *   0.05893) + 
 (pct2race *  -0.03953) + 
 (constant *  -5.21431)
if MRMRACE==7;

gen AItemp7= exp(mrm7AI)/(1+exp(mrm7AI)+exp(mrm7API)+exp(mrm7B)) if MRMRACE==7;
gen APItemp7= exp(mrm7API)/(1+exp(mrm7API)+exp(mrm7API)+exp(mrm7B)) if MRMRACE==7;
gen Btemp7= exp(mrm7B)/(1+exp(mrm7API)+exp(mrm7API)+exp(mrm7B)) if MRMRACE==7;
gen resc7=AItemp7+APItemp7+Btemp7 if MRMRACE==7;
gen rescale7=1/resc7;  
replace AIPROB  = AItemp7  * rescale7 if MRMRACE==7;
replace APIPROB = APItemp7 * rescale7 if MRMRACE==7;
replace BPROB = Btemp7   * rescale7 if MRMRACE==7;
drop  mrm7AI mrm7API mrm7B APItemp7 AItemp7 Btemp7 resc7 rescale7;

* MRMRACE=8 IS AI-API-W  ==> predict AI and API, white is remainder;
gen mrm8AI =0; label variable mrm8AI "regression answer: AI, MRD group 8";
replace mrm8AI =
 (notAI    *   0) +
 (notAPI   *   2.83058) + 
 (notB     *   0.97010) + 
 (AGE10    *  -0.03967) + 
 (HISP     *   0.84013) + 
 (MALE     *   0.01914) + 
 (northest *   0.59649) + 
 (midwest  *   0.43237) +
 (south    *  -0.22255) + 
 (bigsubrb *   0.15744) + 
 (medmetro *  -0.17318) + 
 (nonmetro *   0.25013) + 
 (lnpctAI  *   0.56512) +
 (pctAPI   *   0.04203) + 
 (pctB     *   0.03921) + 
 (pct2race *  -0.09723) + 
 (constant *  -5.29417) 
if MRMRACE==8;

gen mrm8API =0; label variable mrm8API "regression answer: API, MRD group 8";
replace mrm8API =
 (notAI    *   2.78725) +
 (notAPI   *   0) + 
 (notB     *   1.61570) + 
 (AGE10    *   0.01946) + 
 (HISP     *   0.21507) + 
 (MALE     *   0.01283) + 
 (northest *  -0.13221) + 
 (midwest  *  -0.15172) +
 (south    *  -0.24854) + 
 (bigsubrb *   0.46028) + 
 (medmetro *  -0.09493) + 
 (nonmetro *  -0.15342) + 
 (lnpctAI  *   0.06996) +
 (pctAPI   *   0.03741) + 
 (pctB     *   0.03590) + 
 (pct2race *   0.06402) + 
 (constant *  -5.73987) 
if MRMRACE==8;

replace AIPROB = exp(mrm8AI) /(1+exp(mrm8AI)+exp(mrm8API)) if MRMRACE==8; 
replace APIPROB= exp(mrm8API)/(1+exp(mrm8AI)+exp(mrm8API)) if MRMRACE==8; 
replace WPROB= 1-AIPROB-APIPROB if MRMRACE==8; 
drop mrm8AI mrm8API; 

* MRMRACE=9 IS AI-B-W ==> predict AI and B, white is remainder;

gen mrm9AI =0; label variable mrm9AI "regression answer: AI, MRD group 9";
replace mrm9AI =
 (AGE10    *  0.26212) + 
 (HISP     *  0.35986) + 
 (MALE     * -0.43898) + 
 (northest * -4.53976) + 
 (midwest  * -3.82328) +
 (south    * -5.73385) + 
 (bigsubrb *  2.78910) + 
 (medmetro *  2.27176) + 
 (nonmetro *  4.17804) + 
 (pctAI    *  0.54579) +
 (pctB     *  0.11100) + 
 (pct2race * -0.23972) + 
 (constant * -0.64594)
if MRMRACE==9;

gen mrm9B =0; label variable mrm9B "regression answer: B, MRD group 9";
replace mrm9B =
 (AGE10    *  0.36140) + 
 (HISP     * -0.83526) + 
 (MALE     *  0.50777) + 
 (northest * -3.45593) + 
 (midwest  * -3.79144) +
 (south    * -2.27313) + 
 (bigsubrb *  2.31011) + 
 (medmetro *  0.75477) + 
 (nonmetro *  1.64725) + 
 (pctAI    *  0.39101) +
 (pctB     *  0.04985) + 
 (pct2race * -0.02919) + 
 (constant *  0.77004)
if MRMRACE==9;

replace AIPROB= exp(mrm9AI)/(1+exp(mrm9AI)+exp(mrm9B)) if MRMRACE==9; 
replace BPROB= exp(mrm9B)/(1+exp(mrm9AI)+exp(mrm9B)) if MRMRACE==9; 
replace WPROB=1-BPROB-AIPROB if MRMRACE==9;
drop mrm9AI mrm9B;

* MARS=10 IS API-B-W  ==> predict API and B, white is remainder;
gen mrm10AP =0; label variable mrm10AP "regression answer: API, MRD group 10";
replace mrm10AP =
 (notAI    *   2.78725) +
 (notAPI   *   0) + 
 (notB     *   1.61570) + 
 (AGE10    *   0.01946) + 
 (HISP     *   0.21507) + 
 (MALE     *   0.01283) + 
 (northest *  -0.13221) + 
 (midwest  *  -0.15172) +
 (south    *  -0.24854) + 
 (bigsubrb *   0.46028) + 
 (medmetro *  -0.09493) + 
 (nonmetro *  -0.15342) + 
 (lnpctAI  *   0.06996) +
 (pctAPI   *   0.03741) + 
 (pctB     *   0.03590) + 
 (pct2race *   0.06402) + 
 (constant *  -5.73987)
if MRMRACE==10;

gen mrm10B =0; label variable mrm10B "regression answer: B, MRD group 10";
replace mrm10B =
 (notAI    *   2.19772) +
 (notAPI   *   3.06153) + 
 (notB     *   0) + 
 (AGE10    *  -0.01691) + 
 (HISP     *  -0.58721) + 
 (MALE     *  -0.08093) + 
 (northest *   0.40115) + 
 (midwest  *   0.20136) +
 (south    *  -0.29365) + 
 (bigsubrb *   0.12070) + 
 (medmetro *  -0.11129) + 
 (nonmetro *  -0.12077) + 
 (lnpctAI  *  -0.00347) +
 (pctAPI   *   0.05396) + 
 (pctB     *   0.05893) + 
 (pct2race *  -0.03953) + 
 (constant *  -5.21431)
if MRMRACE==10;

replace APIPROB= exp(mrm10AP)/(1+exp(mrm10AP)+exp(mrm10B)) if MRMRACE==10; 
replace BPROB= exp(mrm10B)/(1+exp(mrm10AP)+exp(mrm10B)) if MRMRACE==10; 
replace WPROB=1-BPROB-APIPROB if MRMRACE==10;
drop mrm10AP mrm10B;

* MARS=11 IS AI-API-B-W ==> predict AI, API, and B, white is remainder;
gen mrm11AI =0; label variable mrm11AI "regression answer: AI, MRD group 11";
replace mrm11AI =
 (notAI    *   0) +
 (notAPI   *   2.83058) + 
 (notB     *   0.97010) + 
 (AGE10    *  -0.03967) + 
 (HISP     *   0.84013) + 
 (MALE     *   0.01914) + 
 (northest *   0.59649) + 
 (midwest  *   0.43237) +
 (south    *  -0.22255) + 
 (bigsubrb *   0.15744) + 
 (medmetro *  -0.17318) + 
 (nonmetro *   0.25013) + 
 (lnpctAI  *   0.56512) +
 (pctAPI   *   0.04203) + 
 (pctB     *   0.03921) + 
 (pct2race *  -0.09723) + 
 (constant *  -5.29417)
if MRMRACE==11;

gen mrm11AP =0; label variable mrm11AP "regression answer: API, MRD group 11";
replace mrm11AP =
 (notAI    *   2.78725) +
 (notAPI   *   0) + 
 (notB     *   1.61570) + 
 (AGE10    *   0.01946) + 
 (HISP     *   0.21507) + 
 (MALE     *   0.01283) + 
 (northest *  -0.13221) + 
 (midwest  *  -0.15172) +
 (south    *  -0.24854) + 
 (bigsubrb *   0.46028) + 
 (medmetro *  -0.09493) + 
 (nonmetro *  -0.15342) + 
 (lnpctAI  *   0.06996) +
 (pctAPI   *   0.03741) + 
 (pctB     *   0.03590) + 
 (pct2race *   0.06402) + 
 (constant *  -5.73987)
if MRMRACE==11;

gen mrm11B =0; label variable mrm11B "regression answer: B, MRD group 11";
replace mrm11B =
 (notAI    *   2.19772) +
 (notAPI   *   3.06153) + 
 (notB     *   0) + 
 (AGE10    *  -0.01691) + 
 (HISP     *  -0.58721) + 
 (MALE     *  -0.08093) + 
 (northest *   0.40115) + 
 (midwest  *   0.20136) +
 (south    *  -0.29365) + 
 (bigsubrb *   0.12070) + 
 (medmetro *  -0.11129) + 
 (nonmetro *  -0.12077) + 
 (lnpctAI  *  -0.00347) +
 (pctAPI   *   0.05396) + 
 (pctB     *   0.05893) + 
 (pct2race *  -0.03953) + 
 (constant *  -5.21431)
if MRMRACE==11;

replace AIPROB= exp(mrm11AI)/(1+exp(mrm11AI)+exp(mrm11AP)+exp(mrm11B)) if MRMRACE==11; 
replace APIPROB= exp(mrm11AP)/(1+exp(mrm11AI)+exp(mrm11AP)+exp(mrm11B)) if MRMRACE==11; 
replace BPROB= exp(mrm11B)/(1+exp(mrm11AI)+exp(mrm11AP)+exp(mrm11B)) if MRMRACE==11; 
replace WPROB=1-AIPROB-APIPROB-BPROB if MRMRACE==11;
drop mrm11AI mrm11AP mrm11B;

drop  lnpctAI pctAI pctAPI pctB pctBsq pct2race medmetro nonmetro 
bigurban bigsubrb constant notAI notAPI notB northest midwest south west;

* Note: When converting probabilities to ONERACE, equal probabilities 
are decided in favor of the single-race group that has a higher average 
probability listed in Table 9 of Ingram et al. 2003.;

gen ONERACE=0; 
replace ONERACE=1 if MRMRACE==20; 
replace ONERACE=2 if MRMRACE==30; 
replace ONERACE=3 if MRMRACE==40; 
replace ONERACE=4 if MRMRACE==50; 
replace ONERACE=5 if MRMRACE==60;

replace ONERACE=1 if MRMRACE==1 & AIPROB>0.5; 
replace ONERACE=2 if MRMRACE==1 & APIPROB>=0.5; 

replace ONERACE=1 if MRMRACE==2 & AIPROB>0.5; 
replace ONERACE=3 if MRMRACE==2 & BPROB>=0.5; 

replace ONERACE=1 if MRMRACE==3 & AIPROB>0.5; 
replace ONERACE=4 if MRMRACE==3 & WPROB>=0.5; 

replace ONERACE=2 if MRMRACE==4 & APIPROB>0.5; 
replace ONERACE=3 if MRMRACE==4 & BPROB>=0.5; 

replace ONERACE=2 if MRMRACE==5 & APIPROB>0.5; 
replace ONERACE=4 if MRMRACE==5 & WPROB>=0.5; 

replace ONERACE=4 if MRMRACE==6 & WPROB>0.5; 
replace ONERACE=3 if MRMRACE==6 & BPROB>=0.5; 

replace ONERACE=2 if MRMRACE==7 & APIPROB>BPROB   & APIPROB>AIPROB; 
replace ONERACE=1 if MRMRACE==7 & AIPROB>=APIPROB & AIPROB>BPROB;
replace ONERACE=3 if MRMRACE==7 & BPROB>=APIPROB  & BPROB>=AIPROB;

replace ONERACE=1 if MRMRACE==8 & AIPROB>APIPROB  & AIPROB>WPROB;
replace ONERACE=2 if MRMRACE==8 & APIPROB>=AIPROB & APIPROB>WPROB;
replace ONERACE=4 if MRMRACE==8 & WPROB>=AIPROB   & WPROB>=APIPROB;

replace ONERACE=1 if MRMRACE==9 & AIPROB>BPROB    & AIPROB>WPROB; 
replace ONERACE=4 if MRMRACE==9 & WPROB>=AIPROB   & WPROB>BPROB;
replace ONERACE=3 if MRMRACE==9 & BPROB>=AIPROB   & BPROB>=WPROB;

replace ONERACE=2 if MRMRACE==10 & APIPROB>BPROB  & APIPROB>WPROB;
replace ONERACE=3 if MRMRACE==10 & BPROB>=APIPROB & BPROB>WPROB;
replace ONERACE=4 if MRMRACE==10 & WPROB>=APIPROB & WPROB>=BPROB;

replace ONERACE=2 if MRMRACE==11 & APIPROB>AIPROB & APIPROB>BPROB & APIPROB>WPROB;
replace ONERACE=1 if MRMRACE==11 & AIPROB>=APIPROB & AIPROB>BPROB & AIPROB>WPROB;
replace ONERACE=3 if MRMRACE==11 & BPROB>=APIPROB & BPROB>=AIPROB & BPROB>WPROB;
replace ONERACE=4 if MRMRACE==11 & WPROB>=APIPROB & WPROB>=AIPROB & WPROB>=BPROB;

label variable ONERACE "bridged single race"; 
label define oneracelbl 1 "Am.Ind." 2 "Asian/PI" 3 "black" 4 "white" 5 "SOR";
label values ONERACE oneracelbl;

# delimit cr


/*** Drop variables not need in the main do-file ***/
drop MRMRACE AGE10 HISP MALE STATEFIP
drop AIPROB APIPROB BPROB WPROB


/*** Clean up the new race variable ***/
replace ONERACE=. if ONERACE==0
replace ONERACE=. if year<2003
replace ONERACE=. if race==20 | race==21






